﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Reflection;

using OpenControls.Core;
using System.Drawing;
using System.ComponentModel;

namespace OpenControls.Controls
{
    public class FormCustomizable : Form, ICustomizableControl
    {
        #region "Private Fields"
        private IControlCustomizer customizer;
        #endregion 

        #region "Public Fields"
        public IStyle Style { get; set; }
        public string CssFile { get; set; }
        public string CssClass { get; set; }
        public bool UseControlParentStyle { get; set; }
        #endregion

        #region "Private Methods"

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // FormCustomizable
            // 
            this.ClientSize = new System.Drawing.Size(330, 257);
            this.Name = "FormCustomizable";
            this.ResumeLayout(false);

        }

        #endregion

        public FormCustomizable()
        {
            InitializeComponent();
        }

        protected override void OnCreateControl()
        {
            base.OnCreateControl();

            if (!this.DesignMode)
            {
                this.customizer = new FormBaseCustomizer();

                if (this.Style == null)
                    this.customizer.LoadMyStyle(this);
                try
                {
                    this.customizer.PerformCustomization(this);
                }
                catch
                {
                    throw;
                }
            }
        }
    }
}
